<?php

/**
 * IndexController - The default controller class
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class Adminb_AuctionorderController extends Zend_Controller_Action 
{
	

	public function init(){
		
		$member=new CMember();
		
		if(!$member->isUser($this->_request->getModuleName(),$this->_request->getControllerName())){
			
			if($_COOKIE[COOKIE_PRE.'uid']!=''){
				
				$this->_redirect(MY_URL.'/buyer');
				
			}else{
			
				$this->_redirect(MY_URL.'/buyer-auth-login');
				
			}
			
		}
		
	}
	
	public function preDispatch()
	{

		$this->getHelper ('layout')->setLayout('framelayout');
		
		$this->view->addHelperPath(MY_ROOT.'/vhelpers');
		
		Zend_Controller_Action_HelperBroker::addPath(MY_ROOT.'/chelpers');
		
		$this->view->assign('currentAction',$this->_request->getActionName());
			
	}

    public function indexAction() 
    {

    	$orderfl=new CFenlei('auction_order');
    	
    	$fenleiArray=$orderfl->getAllFenlei();
    	
    	$orderfl->fenleiLang='en_flname';
		
		$orderfl->getAll($fenleiArray,0);
		
		$fenleiString=str_replace(array('<div class="smallChildDiv"></div>','<div></div>'),array('',''),$orderfl->fenleiString);

		$this->view->assign('fenleiString',$fenleiString);
		
		$this->view->assign('fenleiArray',$fenleiArray);

    }
    
    public function getitemajaxAction(){
    	
    	$this->getHelper ('layout')->disableLayout ();
    	
    	$flid=$this->_request->getParam('flid',0);
    	
    	$page=$this->_request->getParam('page',1);
    	
    	$order=new CAuctionOrder();
    	
    	$where=array();
    	
    	if($flid!=0){
    		
    		$where[]=R_PRE."auction_orders.flid='$flid'";
    		
    	}
		
    	$where=join(' AND ',$where);
    	
		$orderCounts=$order->getAllOrderCounts($_COOKIE[COOKIE_PRE.'uid'],$where);
		
		Zend_Loader::loadClass("CFilter");
    	
    	$pageArray = CFilter::filterPage ( $page, $orderCounts, 10 );
		
		$orderArray=$order->getAllOrders($pageArray['from'],10,$_COOKIE[COOKIE_PRE.'uid'],$where);
		
		Zend_Loader::loadClass("CPage");
    	
    	$pageString = CPage::commonDivAjax($pageArray ['pageNumber'], $pageArray ['page'], 'productEffection.showAll',$flid); //生成分页字符串
    	
    	$this->view->assign ( "pageString", $pageString );
    	
    	$this->view->assign ( "pageArray", $pageArray );

		$this->view->assign ( 'orderArray', $orderArray );
    	
    }
    

    public function moreAction(){
    	
    	$orderid=$this->_request->getParam('orderid');
    	
    	$order=new CAuctionOrder();
    	
    	$orderArray=$order->getDetail($orderid);
    	
    	$this->view->assign('orderArray',$orderArray);
    	
    	$itemArray=array();
    	
    	$itemArray=unserialize($orderArray[0]['order_string']);
    	
    	$this->view->assign('itemArray',$itemArray);
    	
    	$orderContact=new COrderContact();
    	
    	$contactArray=$orderContact->getAllContacts(0,1,$orderArray[0]['uid']);
    	
    	$fenlei=new CFenlei('location');
    	
    	$locationName=$fenlei->getFenLeiNameByFlid($contactArray[0]['location_id']);
    	
    	$this->view->assign('contactArray',$contactArray);
    	
    	$this->view->assign('locationName',$locationName);

    }
 
	public function postAction(){
	
		//$this->_helper->viewRenderer->setNoRender();
		
		//$this->getHelper ('layout')->disableLayout ();
	
	}
    

    
}
